dvb-usb: Don't use stack for reset either
authorBen Hutchings <ben@decadent.org.uk>
Wed, 1 Mar 2017 15:39:17 +0000 (15:39 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 30 Mar 2017 01:16:33 +0000 (01:16 +0000)
Commit 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware
load") introduced a heap buffer for the firmware writes, but we need
to do the same for the register writes to reset the DVB device's
processor.

Cc: stable@vger.kernel.org # 4.9+
Fixes: 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware load")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name media-dvb-usb-don-t-use-stack-for-reset-either.patch

drivers/media/usb/dvb-usb/dvb-usb-firmware.c

index ae0218b09b19dd0f37de3dae78924596bcb85786..72a25534ae7017279edda3f6d62675308331f97d 100644 (file)
@@ -36,16 +36,17 @@ static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 le
 int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
 {
        struct hexline *hx;
-       u8 reset;
+       u8 *reset;
        int ret,pos=0;
 
        hx = kmalloc(sizeof(*hx), GFP_KERNEL);
        if (!hx)
                return -ENOMEM;
+       reset = (u8 *)hx;
 
        /* stop the CPU */
-       reset = 1;
-       if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)
+       *reset = 1;
+       if ((ret = usb_cypress_writemem(udev, cypress[type].cpu_cs_register, reset, 1)) != 1)
                err("could not stop the USB controller CPU.");
 
        while ((ret = dvb_usb_get_hexline(fw, hx, &pos)) > 0) {
@@ -68,8 +69,8 @@ int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw
 
        if (ret == 0) {
                /* restart the CPU */
-               reset = 0;
-               if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) {
+               *reset = 0;
+               if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register, reset, 1) != 1) {
                        err("could not restart the USB controller CPU.");
                        ret = -EINVAL;
                }